/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spiele.odtd;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author martin
 */
public class LineOfDefense {
  public List<Unit> AattackB(final List<Unit> a, final List<Unit> b){
    List<Unit> yeild = new ArrayList();
    
    for (Unit attacker : a){
      int indexA = a.indexOf(attacker);
      List<Integer> targets = attacker.targetFrom(indexA);
      for (Unit defender : b){
        int indexB = b.indexOf(defender);
        if (targets.contains(indexB)){
          yeild.add(defender.attackedby(attacker));
        }
        else{
          yeild.add(defender);
        }
      }
    }
    
    return yeild;
  }
}
